/*
 * Copyright (C) 2003, Velocityme Partnership
 * TaskStateMachineBean.java
 *
 * Created on 07 May 2003, 06:45
 */

package com.velocityme.entity;

import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.*;
import java.util.*;
import com.velocityme.interfaces.*;
import com.velocityme.valueobjects.TaskStateMachineValue;

/**
 *
 * @author  Robert Crida Work
 * @ejb.bean
 *           type="CMP"
 *           cmp-version="2.x"
 *           name="TaskStateMachine"
 *           jndi-name="ejb/TaskStateMachine"
 *           view-type="local"
 * @ejb.transaction type="Required"
 *
 * @ejb.value-object match="*"
 *
 * @ejb.persistence table-name="taskstatemachine"
 *
 * @ejb.util generate="physical"
 *
 * @ejb.finder signature="java.util.Collection findAll()"
 *              query="SELECT OBJECT(o) FROM TaskStateMachine o WHERE o.nodeLocal.dBObjectLocal.isDeleted = FALSE"
 *
 * @ejb.finder signature="com.velocityme.interfaces.TaskStateMachine findDefault()"
 *              query="SELECT OBJECT(o) FROM TaskStateMachine o WHERE o.nodeLocal.name = 'Default'"
 *
 * @jboss.persistence create-table="true"
 *                    remove-table="false"
 */
public abstract class TaskStateMachineBean implements EntityBean {
    
    /**
    * Context set by container
    */
    private javax.ejb.EntityContext m_entityContext;

    public void setEntityContext(javax.ejb.EntityContext entityContext) {
        m_entityContext = entityContext;
    }

    public void unsetEntityContext() {
        m_entityContext = null;
    }
  
    /** @ejb.create-method */
    public com.velocityme.interfaces.TaskStateMachinePK ejbCreate(com.velocityme.interfaces.NodeLocal p_nodeLocal,
                                                                  com.velocityme.valueobjects.TaskStateMachineValue p_value) throws CreateException {
        setTaskStateMachineId(p_nodeLocal.getNodeId());
        // EJB 2.0 spec says return null for CMP ejbCreate methods.
        return null;
    }

    public void ejbPostCreate(com.velocityme.interfaces.NodeLocal p_nodeLocal,
                              com.velocityme.valueobjects.TaskStateMachineValue p_value) throws CreateException {
        // CMR relations must be set in ejbPostCreate
        setTaskStateMachineValue(p_value);
        setNodeLocal(p_nodeLocal);
    }

    /**
     *  This gets a local object from a remote object.
     *  @ejb.interface-method view-type="remote"
     */
    public com.velocityme.interfaces.TaskStateMachineLocal getLocal() {
        return (TaskStateMachineLocal)m_entityContext.getEJBLocalObject();
    }
    
    /** @ejb.interface-method view-type="local" */
    public abstract com.velocityme.valueobjects.TaskStateMachineValue getTaskStateMachineValue();
    /** @ejb.interface-method view-type="local" */
    public abstract void setTaskStateMachineValue(com.velocityme.valueobjects.TaskStateMachineValue taskStateMachineValue);
    
    //=======================================================================
    //
    //                   ATTRIBUTES
    //
    //=======================================================================
      
    /**
     * @ejb.persistence column-name="taskStateMachineId"
     * @ejb.interface-method view-type="local"
     * @ejb.pk-field 
     */
    public abstract java.lang.Integer getTaskStateMachineId();
    /** @ejb.interface-method view-type="local" */
    public abstract void setTaskStateMachineId(java.lang.Integer taskStateMachineId);

    //=======================================================================
    //
    //                   RELATIONSHIPS
    //
    //=======================================================================
    
    /**
     * @ejb.interface-method view-type="local"
     * @ejb.relation name="TaskStateMachine-Node"
     *               role-name="TaskStateMachine-has-a-Node"
     * @jboss.relation fk-column="nodeIdFk"
     *                 related-pk-field="nodeId"
     * @ejb.value-object match="*" 
     *                   aggregate="com.velocityme.valueobjects.NodeValue"
     *                   aggregate-name="NodeValue"
     */
    public abstract com.velocityme.interfaces.NodeLocal getNodeLocal();
    /** @ejb.interface-method view-type="local" */
    public abstract void setNodeLocal(com.velocityme.interfaces.NodeLocal nodeLocal);
    
    /**
     * @ejb.interface-method view-type="local"
     * @ejb.relation name="TaskStateMachine-Transition"
     *               role-name="TaskStateMachine-has-many-Transitions"
     * @ejb.value-object match="*"
     *                   aggregate="com.velocityme.valueobjects.TransitionValue"
     *                   aggregate-name="TransitionValue"
     *                   members="com.velocityme.interfaces.TransitionLocal"
     *                   members-name="TransitionLocal"
     *                   relation="external"
     *                   type="Collection"
     */
    public abstract java.util.Collection getTransitionsLocal();
    /** @ejb.interface-method view-type="local" */
    public abstract void setTransitionsLocal(java.util.Collection transitionsLocal);
    
    /**
     * @ejb.interface-method view-type="local"
     * @ejb.relation name="TaskStateMachine-Role"
     *               role-name="TaskStateMachine-may-have-many-InterestedRoles"
     * @jboss.relation fk-column="taskStateMachineId"
     *                 related-pk-field="roleId"
     * @jboss.relation-table table-name="taskstatemachineinterestedroles"
     *                       create-table="true"
     *                       remove-table="false"
     * @ejb.value-object match="*" 
     *                   aggregate="com.velocityme.valueobjects.RoleValue"
     *                   aggregate-name="InterestedRoleValue"
     *                   members="com.velocityme.interfaces.RoleLocal"
     *                   members-name="RoleLocal"
     *                   relation="external"
     *                   type="Collection"
     */
    public abstract java.util.Collection getInterestedRolesLocal();
    /** @ejb.interface-method view-type="local" */
    public abstract void setInterestedRolesLocal(java.util.Collection rolesLocal);
    
    //=======================================================================
    //
    //                   MANAGEMENT METHODS
    //
    //=======================================================================
    
}
